package com.scalar.chiptrack.adaptor.msilica;

import com.scalar.chiptrack.jobs.JobHandler;
import com.scalar.chiptrack.adaptor.AdaptorConstants;
import com.scalar.chiptrack.adaptor.InventoryLot;
import com.scalar.chiptrack.adaptor.AssemblyLot;
import com.scalar.chiptrack.adaptor.TestLot;
import com.scalar.chiptrack.adaptor.AdaptorUtils;
import com.scalar.chiptrack.adaptor.utils.ParserResult;
import com.scalar.chiptrack.adaptor.utils.Parser;
import com.scalar.chiptrack.adaptor.utils.ParserFactory;
import com.scalar.chiptrack.adaptor.utils.CSVParserImpl;
import com.scalar.chiptrack.adaptor.ikanos.asecl.ASECLPOP3Adaptor;
import com.scalar.chiptrack.adaptor.dao.AssemblyAdaptorDAO;
import com.scalar.chiptrack.adaptor.dao.TestAdaptorDAO;
import com.scalar.chiptrack.adaptor.dao.InventoryLotDAO;
import com.scalar.chiptrack.adaptor.dao.FabSortAdaptorDAO;
import com.scalar.chiptrack.adaptor.dao.ShippedLotDAO;
import com.scalar.chiptrack.adaptor.dao.AdaptorDAO;
import com.scalar.chiptrack.adaptor.dao.AdaptorRunInfo;
import com.scalar.chiptrack.utils.Logger;
import com.scalar.chiptrack.utils.StringUtils;
import com.scalar.chiptrack.utils.DateUtil;
import com.scalar.ScalarException;

import java.util.HashMap;
import java.util.ArrayList;
import java.util.Date;
import java.io.File;

/**
 * Created by IntelliJ IDEA.
 * User: munugoti
 * Date: 15 Apr, 2010
 * Time: 10:36:21 AM
 * To change this template use File | Settings | File Templates.
 */
public class ASECLDataParser extends JobHandler implements AdaptorConstants
{
    private HashMap<String, InventoryLot> m_dieBankDataMap   = new HashMap<String, InventoryLot>();
    private HashMap<String, AssemblyLot> m_assemblyDataMap   = new HashMap<String, AssemblyLot>();
    private HashMap<String, TestLot> m_ftDataMap             = new HashMap<String, TestLot>();
    private HashMap<String, InventoryLot> m_fgDataMap        = new HashMap<String, InventoryLot>();

    private Logger m_parserLogger   = null;
    private String m_dataOutputDir  = null;


    public ASECLDataParser() throws ScalarException
    {
        try
        {
            m_dataOutputDir = AdaptorUtils.getDataOutputDir(VENDOR_NAME_IKANOS_ASECL, WIP_TYPE_ASSEMBLY);
            AdaptorUtils.makeAllAdaptorDirs( m_dataOutputDir );
            m_parserLogger = AdaptorUtils.getDataParserLogger( m_dataOutputDir,VENDOR_NAME_IKANOS_ASECL );
            AssemblyAdaptorDAO.setLogger( m_parserLogger );
            TestAdaptorDAO.setLogger( m_parserLogger );
            InventoryLotDAO.setLogger(m_parserLogger);
            FabSortAdaptorDAO.setLogger(m_parserLogger);
            ShippedLotDAO.setLogger( m_parserLogger );
            AdaptorUtils.setLogger( m_parserLogger );
        }
        catch (ScalarException se)
        {
            log("ERROR!! ERROR!! ERROR!! Exception while loading ASECL WIP output directory details from database, Exception: " + se);
            throw se;
        }
    }
    /**
     *
     * @param args
     * @throws Exception
     */
    public static void main( String args[] ) throws Exception
    {
        try
        {
            new ASECLDataParser().execute();
        }
        catch (Exception e)
        {
            throw e;
        }
    }
    /**
     *
     * @throws Exception
     */
    public void execute() throws Exception
    {
        AdaptorUtils.printHeader(VENDOR_NAME_IKANOS_ASECL, CONSTANT_PARSER);

        File doneDestDir = new File(  m_dataOutputDir + "/done" );

        File sourceDataoutDir = new File( m_dataOutputDir );

        File[] fileList = sourceDataoutDir.listFiles();
        if ( ( fileList == null ) || ( fileList.length <= 3 ) )
        {
            log( "No file found in directory: " + sourceDataoutDir );
            throw new ScalarException( "\n+-----------No file found in directory " + sourceDataoutDir );
        }

        ArrayList successFileList = new ArrayList();

        boolean success = false;

        for ( int i = 0; i < fileList.length; i++ )
        {
            if ( fileList[i].isDirectory() == true )
            {
                continue;
            }

            try
            {
                // Step 1
                // Parse Files to get Object List
                if ( fileList[i].getName() != null && fileList[i].getName().trim().startsWith( ASECLPOP3Adaptor.FILE_NAME_WIP ) )
                {
                    // To parse the the ASECL_WIP_STATUS sheet in to table
                    parseTurnKeyWipReport( fileList[i].getAbsolutePath() );

                    successFileList.add( fileList[i] );
                }

                success = true;
            }
            catch ( Exception e )
            {
                success = false;
                log( "Exception while parsing and storing file: " + fileList[i].getAbsolutePath() + "\nException: " + e );
                e.printStackTrace();
                throw e;
            }
        }

        /*Updating the Die Bank Lot Information*/
        try
        {
            // Save Die Bank Information
            if (m_dieBankDataMap.isEmpty() == false)
            {
                log(" Updating Die Bank Lot Information");
                InventoryLotDAO.saveInventoryLot(null, m_dieBankDataMap.values().iterator(), LOCATION_TYPE_DIE_BANK, VENDOR_NAME_IKANOS_ASECL);
            }
            else
            {
                InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_DIE_BANK, VENDOR_NAME_IKANOS_ASECL);
            }
            success = true;
            m_dieBankDataMap.clear();
            m_dieBankDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log("ERROR!! ERROR!! ERROR!! Could not update Die Bank Lot information into database: " + se);
            throw se;
        }
        /*Assembly Lot Saving*/
        try
        {
            // Save Assembly Information
            if ( m_assemblyDataMap.isEmpty() == false )
            {
                log( " Updating Assembly Lot Information" );
                AssemblyAdaptorDAO.saveAssemblyLot( null, m_assemblyDataMap.values().iterator(), WIP_TYPE_ASSEMBLY, VENDOR_NAME_IKANOS_ASECL );
            }
            else
            {
                AssemblyAdaptorDAO.closeAssemblyLot( null, WIP_TYPE_ASSEMBLY, VENDOR_NAME_IKANOS_ASECL);
            }
            success = true;
            m_assemblyDataMap.clear();
            m_assemblyDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log( "ERROR!! ERROR!! ERROR!! Could not update Assembly Lot information into database: " + se );
            throw se;
        }

        // Saving the Test Lot Information
        try
        {
            // Save Final Test Information
            if ( m_ftDataMap.isEmpty() == false )
            {
                log( " Updating Test Lot Information" );
                TestAdaptorDAO.saveTestLot( null, m_ftDataMap.values().iterator(), LOCATION_TYPE_FT, VENDOR_NAME_IKANOS_ASECL );
            }
            else
            {
                TestAdaptorDAO.closeTestLot( null, LOCATION_TYPE_FT, VENDOR_NAME_IKANOS_ASECL );
            }

            success = true;
            m_ftDataMap.clear();
            m_ftDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log( "ERROR!! ERROR!! ERROR!! Could not update Test Lot information into database: " + se );
            throw se;
        }

        // to save the FG lot tables
       try
       {
          if ( m_fgDataMap.isEmpty() == false )
          {
              log(" Updating Finshed Goods Lot Information");
              InventoryLotDAO.saveInventoryLot( null, m_fgDataMap.values().iterator(), LOCATION_TYPE_FG, VENDOR_NAME_IKANOS_ASECL );
              success = true;
          }
          else
          {
              InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_FG, VENDOR_NAME_IKANOS_ASECL  );
          }
      }
      catch (ScalarException se)
      {
         success = false;
         se.printStackTrace();
         log("ERROR!! ERROR!! ERROR!! Could not update Finshed Goods Lot information into database: " + se);
         throw se;
      }

       // To Close the Drop Out Lots
        AdaptorDAO.closeDropOutLots(VENDOR_NAME_IKANOS_ASECL);

         // TO SEND THE NEW LOTS, NEW TRANSIT LOTS, NO PO LOTS, DISCREPANCY LOTS NOTIFICATIONS TO THE USER
        AdaptorDAO.sendAllNotifications(VENDOR_NAME_IKANOS_ASECL, true, true, true);



       int adaptor_id = AdaptorRunInfo.getLastRunAdaptorId( ASECLPOP3Adaptor.ADAPTOR_NAME, CONSTANT_ADAPTOR);

        // Update Adaptor_Run_Info table
        try
        {
            if ( success == true )
            {
                AdaptorRunInfo.saveAdaptorLastUpdatedStatus(CONSTANT_PARSER, ASECLPOP3Adaptor.ADAPTOR_NAME, CONSTANT_SUCCESS, adaptor_id);
                System.out.println( "SUCCESSFULLY UPDATED IN THE DATABASE" );
            }
        }
        catch ( ScalarException se )
        {
            success = false; //As filES DATA SAVED , UPDATEING AS SUCCESS
            AdaptorRunInfo.saveAdaptorLastUpdatedStatus(CONSTANT_PARSER, ASECLPOP3Adaptor.ADAPTOR_NAME, CONSTANT_SUCCESS, adaptor_id);
            log( "WARNING!! WARNING!! WARNING!! Could not update Adaptor run information, Exception: " + se );
            throw se;
        }
        // Move the successful files to 'done' directory
       if ( success )
       {
           AdaptorUtils.moveFilesToDone( successFileList, doneDestDir );
       }
    }

    private void parseTurnKeyWipReport( String fileName ) throws Exception
    {
        if ( fileName == null ) throw new ScalarException( "Filename argument is null" );

        ParserResult result            = null;
        TestLot testLot         = null;
        InventoryLot inventoryLot = null;
        AssemblyLot assemblyLot  = null;
        String lotNumber        = null;
        String partNumber       = null;
        String fablotNumber     = null;
        try
        {
            File detailWipFile = new File( fileName );
            if ( detailWipFile.exists() == false )
            {
                throw new ScalarException( fileName + " doesnt exist" );
            }

            log( "\nFound " + fileName );
            log( "\nParsing the file for Turn Key Wip Report..." );
            System.out.println( "\nFound " + fileName );
            System.out.println( "\nParsing the file for Turn Key Wip Report..." );
             char delim;
             if ( fileName.indexOf("csv") != -1 || fileName.indexOf("CSV") != -1 )
             {
                 delim = ',';
             }
             else
             {
                 delim = '\t';
             }

             Parser parser = ParserFactory.getCSVParser( detailWipFile, delim );

            ((CSVParserImpl)parser).setHeaderRowIdx(0);
            ((CSVParserImpl)parser).setDataStartRowIdx(1);

            result = parser.parse();

            while ( result.next() )
            {
                partNumber = result.getString("Device");
                fablotNumber = result.getString("Cust Lot No");
                lotNumber   =  result.getString("ASE Lot");
                if ( lotNumber == null )
                {
                    lotNumber = fablotNumber;
                }
                if (partNumber!= null && partNumber.trim().length() >0 && lotNumber != null && lotNumber.trim().length() > 0 )
                {
                    if ( result.getString("Unissue DBank") != null && !"0".equalsIgnoreCase( result.getString("Unissue DBank") ) )
                    {
                        if ( partNumber.endsWith("-00") )
                        {
                            partNumber = partNumber.substring(0, partNumber.lastIndexOf("-00") );
                        }
                        log( lotNumber +" In DieBank");

                        inventoryLot = (InventoryLot)m_dieBankDataMap.get( partNumber + fablotNumber );

                        if ( inventoryLot == null )
                        {
                            inventoryLot = new InventoryLot( VENDOR_NAME_IKANOS_ASECL, LOCATION_TYPE_DIE_BANK );
                            m_dieBankDataMap.put( partNumber + fablotNumber, inventoryLot );
                        }

                        if( inventoryLot.getQtyIn() != null )
                        {
                             try
                             {
                                 inventoryLot.setQtyIn( ( Integer.parseInt( inventoryLot.getQtyIn() ) + Integer.parseInt( result.getString("Unissue DBank") ) ) + "" );
                                 inventoryLot.setWaferQtyIn(( Integer.parseInt( inventoryLot.getWaferQtyIn() ) + Integer.parseInt( result.getString("Unissue WBank") ) ) + "" );
                             }
                             catch(Exception e)
                             {
                                 inventoryLot.setQtyIn( result.getString("Unissue DBank") );
                                 inventoryLot.setWaferQtyIn( result.getString("Unissue WBank") );
                             }
                         }
                         else
                         {
                             inventoryLot.setQtyIn( result.getString("Unissue DBank") );
                             inventoryLot.setWaferQtyIn( result.getString("Unissue WBank") );
                         }

                         if ( inventoryLot.getQtyIn() != null && !"0".equalsIgnoreCase(inventoryLot.getQtyIn() ) )
                         {
                            inventoryLot.setPartNumber( partNumber );
                            inventoryLot.setLotNumber( fablotNumber );
                            if ( result.getDate("Recv Date", "yyyy/MM/dd") != null )
                            {
                                inventoryLot.setDateIn( StringUtils.formatDateToString( result.getDate("Recv Date", "yyyy/MM/dd"), "MM/dd/yyyy" ) );
                            }
                            inventoryLot.setFabLotNumber( fablotNumber );
                            inventoryLot.setPkgType( result.getString("PKG Type") );
                            inventoryLot.setLeadCount( result.getString("L/C") );
                            inventoryLot.setDateCode( result.getString("Date Code") );
                            inventoryLot.setCustomerPO( result.getString("Release No"));
                            inventoryLot.setStatus( LOT_STATUS_RUNNING );
                            if ( lotNumber.endsWith("R") )
                            {
                                inventoryLot.setLotCategory( LOT_CATEGORY_TYPE_RMA );
                            }
                            else
                            {
                                inventoryLot.setLotCategory( LOT_CATEGORY_TYPE_PROD );
                            }
                        }
                    }

                     //ASSEMBLY
                    if (  result.getString("Wafer Grinding") != null && !"0".equalsIgnoreCase(result.getString("Wafer Grinding") )
                            || result.getString("Die Attach") != null && !"0".equalsIgnoreCase( result.getString("Die Attach") )
                            || result.getString("Wire Bond") != null && !"0".equalsIgnoreCase( result.getString("Wire Bond") )
                            || result.getString("Molding") != null && !"0".equalsIgnoreCase( result.getString("Molding") )
                            || result.getString("Leaser Marking") != null && !"0".equalsIgnoreCase( result.getString("Leaser Marking") )
                            || result.getString("Plating") != null && !"0".equalsIgnoreCase( result.getString("Plating") )
                            || result.getString("Forming") != null && !"0".equalsIgnoreCase( result.getString("Forming") )
                            || result.getString("Final Visual Inspection") != null && !"0".equalsIgnoreCase( result.getString("Final Visual Inspection") )
                            || result.getString("Assy Hold") != null && !"0".equalsIgnoreCase( result.getString("Assy Hold") )
                            || result.getString("AS FG Bank") != null && !"0".equalsIgnoreCase( result.getString("AS FG Bank") )
                            || result.getString("FT Intra") != null && !"0".equalsIgnoreCase(result.getString("FT Intra")) )

                   {
                        log( "In Assembly" + lotNumber ) ;

                        assemblyLot = (AssemblyLot) m_assemblyDataMap.get( partNumber + lotNumber + fablotNumber );
                        if (assemblyLot == null)
                        {
                            assemblyLot = new AssemblyLot(VENDOR_NAME_IKANOS_ASECL );
                            m_assemblyDataMap.put( partNumber + lotNumber + fablotNumber, assemblyLot);
                        }

                        // FOR SETTING THE QTY IN
                        if( result.getString("Wafer Grinding") != null && !"0".equalsIgnoreCase(result.getString("Wafer Grinding") ) )
                        {
                           assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);
                           if( assemblyLot.getQtyIn() != null )
                           {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("Wafer Grinding") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("Wafer Grinding") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("Wafer Grinding") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", Grinding") ;
                            }
                            else
                            {
                                assemblyLot.setStage("Grinding");
                            }
                        }
                        if(result.getString("Die Attach") != null && !"0".equalsIgnoreCase( result.getString("Die Attach") ) )
                        {
                           assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);
                           if( assemblyLot.getQtyIn() != null )
                           {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("Die Attach") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("Die Attach") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("Die Attach") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", Die Attach") ;
                            }
                            else
                            {
                                assemblyLot.setStage("Die Attach");
                            }
                        }
                        if(result.getString("Wire Bond") != null && !"0".equalsIgnoreCase(result.getString("Wire Bond")) )
                        {
                           assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);

                           if( assemblyLot.getQtyIn() != null )
                           {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("Wire Bond") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("Wire Bond") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("Wire Bond") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", Wire Bond") ;
                            }
                            else
                            {
                                assemblyLot.setStage("Wire Bond");
                            }
                        }

                        if( result.getString("Molding") != null && !"0".equalsIgnoreCase( result.getString("Molding") ) )
                        {
                           assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);
                           if( assemblyLot.getQtyIn() != null )
                           {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("Molding") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("Molding") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("Molding") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", MoldIng") ;
                            }
                            else
                            {
                                assemblyLot.setStage("Molding");
                            }
                        }

                        if( result.getString("Leaser Marking") != null && !"0".equalsIgnoreCase( result.getString("Leaser Marking") ) )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);
                           if( assemblyLot.getQtyIn() != null )
                           {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("Leaser Marking") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("Leaser Marking") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("Leaser Marking") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", Marking") ;
                            }
                            else
                            {
                                assemblyLot.setStage("Marking");
                            }
                        }

                        if( result.getString("Plating") != null && !"0".equalsIgnoreCase( result.getString("Plating") ) )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);
                           if( assemblyLot.getQtyIn() != null )
                           {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("Plating") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("Plating") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("Plating") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", Plating") ;
                            }
                            else
                            {
                                assemblyLot.setStage("Plating");
                            }
                        }
                        if( result.getString("Forming") != null && !"0".equalsIgnoreCase(result.getString("Forming") ) )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);
                           if( assemblyLot.getQtyIn() != null )
                           {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("Forming") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("Forming") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("Forming") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", Forming") ;
                            }
                            else
                            {
                                assemblyLot.setStage("Forming");
                            }
                        }
                       if( result.getString("Final Visual Inspection") != null && !"0".equalsIgnoreCase( result.getString("Final Visual Inspection") ) )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);
                           if( assemblyLot.getQtyIn() != null )
                           {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("Final Visual Inspection") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("Final Visual Inspection") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("Final Visual Inspection") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", FVI") ;
                            }
                            else
                            {
                                assemblyLot.setStage("FVI");
                            }
                        }
                        if( result.getString("Assy Hold") != null && !"0".equalsIgnoreCase( result.getString("Assy Hold") ) )
                        {
                           assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);
                           if( assemblyLot.getQtyIn() != null )
                           {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("Assy Hold") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("Assy Hold") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("Assy Hold") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", Assy Hold") ;
                            }
                            else
                            {
                                assemblyLot.setStage("Assy Hold");
                            }
                        }

                        if( result.getString("AS FG Bank") != null && !"0".equalsIgnoreCase( result.getString("AS FG Bank") ) )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);
                            if( assemblyLot.getQtyIn() != null )
                            {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("AS FG Bank") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("AS FG Bank") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("AS FG Bank") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", Assy FG Bank") ;
                            }
                            else
                            {
                                assemblyLot.setStage("Assy FG Bank");
                            }
                        }
                        if( result.getString("FT Intra") != null && !"0".equalsIgnoreCase( result.getString("FT Intra") ) )
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(partNumber + lotNumber + fablotNumber);
                            if( assemblyLot.getQtyIn() != null )
                            {
                                try
                                {
                                    assemblyLot.setQtyIn( ( Integer.parseInt( assemblyLot.getQtyIn() ) + Integer.parseInt( result.getString("FT Intra") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    assemblyLot.setQtyIn( result.getString("FT Intra") );
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn( result.getString("FT Intra") );
                            }
                            if ( assemblyLot.getStage() != null )
                            {
                                assemblyLot.setStage ( assemblyLot.getStage() +", Assy InTransit") ;
                            }
                            else
                            {
                                assemblyLot.setStage("Assy InTransit");
                            }
                        }

                        assemblyLot.setLotNumber( lotNumber );
                        assemblyLot.setDeviceName( partNumber );
                        if ( result.getString("Assy Hold") != null && !"0".equalsIgnoreCase(result.getString("Assy Hold")) )
                        {
                           assemblyLot.setStatus(LOT_STATUS_HOLD);
                           assemblyLot.setHoldReason( result.getString("Assy Hold Code") );
                           assemblyLot.setHoldCode( result.getString("Assy Hold Reason") );
                        }
                        else
                        {
                           assemblyLot.setStatus(LOT_STATUS_RUNNING);
                        }
                        assemblyLot.setFabLotNumber( fablotNumber );
                        assemblyLot.setPackageType( result.getString("PKG Type") );
                        assemblyLot.setLeadCount( result.getString("L/C") );
                        assemblyLot.setDateCode( result.getString("Date Code") );
                        if ( lotNumber.endsWith("R") )
                        {
                            assemblyLot.setCategory( LOT_CATEGORY_TYPE_RMA );
                        }
                        else
                        {
                            assemblyLot.setCategory( LOT_CATEGORY_TYPE_PROD );
                        }


                        if ( result.getDate("Iss Date", "yyyy/MM/dd") != null )
                        {
                            assemblyLot.setDateIn( StringUtils.formatDateToString(result.getDate("Iss Date", "yyyy/MM/dd"), "MM/dd/yyyy" ) );
                        }
                        else if (result.getDate("Recv Date", "yyyy/MM/dd") != null )
                        {
                            assemblyLot.setDateIn( StringUtils.formatDateToString(result.getDate("Recv Date", "yyyy/MM/dd"), "MM/dd/yyyy" ) );
                        }
                        if (result.getDate("Revised SOD", "yyyy/MM/dd") != null )
                        {
                            assemblyLot.setExpectedDateOut( StringUtils.formatDateToString(result.getDate("Revised SOD", "yyyy/MM/dd"), "MM/dd/yyyy" ) );
                        }
                        else if ( result.getDate("Assy SOD", "yyyy/MM/dd") != null )
                        {
                             assemblyLot.setExpectedDateOut( StringUtils.formatDateToString(result.getDate("Assy SOD", "yyyy/MM/dd"), "MM/dd/yyyy" ) );
                        }
                        assemblyLot.setPONumber( result.getString("Release No"));
                        assemblyLot.setProcessType( WIP_TYPE_ASSEMBLY );
                    }

                    // FT Process  FT1, FT2, FT3, FT4_6, FTX, BI, FT Hold
                    if (  result.getString("FT Uniss") != null && !"0".equalsIgnoreCase( result.getString("FT Uniss") )
                        || result.getString("FT1") != null && !"0".equalsIgnoreCase( result.getString("FT1") )
                        || result.getString("FT2") != null && !"0".equalsIgnoreCase( result.getString("FT2") )
                        || result.getString("FT3") != null && !"0".equalsIgnoreCase( result.getString("FT3") )
                        || result.getString("FT4_6") != null && !"0".equalsIgnoreCase( result.getString("FT4_6") )
                        || result.getString("FTX") != null && !"0".equalsIgnoreCase( result.getString("FTX") )
                        || result.getString("BI") != null && !"0".equalsIgnoreCase( result.getString("BI") )
                        || result.getString("FT Hold") != null && !"0".equalsIgnoreCase( result.getString("FT Hold") )
                        || result.getString("TM") != null && !"0".equalsIgnoreCase( result.getString("TM") )
                        || result.getString("SBM") != null && !"0".equalsIgnoreCase( result.getString("SBM") )
                        || result.getString("VM") != null && !"0".equalsIgnoreCase( result.getString("VM") )
                        || result.getString("BK") != null && !"0".equalsIgnoreCase( result.getString("BK") )
                        || result.getString("TR") != null && !"0".equalsIgnoreCase( result.getString("TR") )
                        || result.getString("PK") != null && !"0".equalsIgnoreCase( result.getString("PK") )
                        || result.getString("FT Else") != null && !"0".equalsIgnoreCase( result.getString("FT Else") )
                        || result.getString("BE Hold") != null && !"0".equalsIgnoreCase( result.getString("BE Hold") )    )
                    {
                        log(lotNumber + "In Test FT");

                        testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                        if (testLot == null)
                        {
                            testLot = new TestLot(VENDOR_NAME_IKANOS_ASECL);
                            m_ftDataMap.put(partNumber + lotNumber + fablotNumber, testLot);
                        }

                       // FOR SETTING THE QTY IN
                       if ( result.getString("FT Uniss") != null && !"0".equalsIgnoreCase( result.getString("FT Uniss") ) )
                       {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );

                            if( testLot.getQtyIn() != null )
                            {
                                 try
                                 {
                                     testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("FT Uniss") ) ) + "" );
                                 }
                                 catch(Exception e)
                                 {
                                     testLot.setQtyIn( result.getString("FT Uniss") );
                                 }
                             }
                             else
                             {
                                 testLot.setQtyIn( result.getString("FT Uniss") );
                             }
                             if ( testLot.getStage() != null )
                             {
                                testLot.setStage( testLot.getStage() + ", FT Uniss");
                             }
                             else
                             {
                                testLot.setStage("FT Uniss");
                             }
                       }
                       if( result.getString("FT1") != null && !"0".equalsIgnoreCase( result.getString("FT1") ) )
                       {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                           if( testLot.getQtyIn() != null )
                           {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("FT1") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("FT1") );
                                }
                            }
                            else
                            {
                                testLot.setQtyIn( result.getString("FT1") );
                            }
                            if ( testLot.getStage() != null )
                            {
                                testLot.setStage( testLot.getStage() + ", FT1");
                            }
                            else
                            {
                                testLot.setStage("FT1");
                            }
                        }
                        if( result.getString("FT2") != null && !"0".equalsIgnoreCase( result.getString("FT2") ) )
                        {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                           if( testLot.getQtyIn() != null )
                           {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("FT2") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("FT2") );
                                }
                            }
                            else
                            {
                                testLot.setQtyIn( result.getString("FT2") );
                            }
                            if ( testLot.getStage() != null )
                            {
                                testLot.setStage( testLot.getStage() + ", FT2");
                            }
                            else
                            {
                                testLot.setStage("FT2");
                            }
                        }
                       if( result.getString("FT3") != null && !"0".equalsIgnoreCase( result.getString("FT3") ) )
                       {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                           if( testLot.getQtyIn() != null )
                           {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("FT3") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("FT3") );
                                }
                            }
                            else
                            {
                                testLot.setQtyIn( result.getString("FT3") );
                            }
                            if ( testLot.getStage() != null )
                            {
                                testLot.setStage( testLot.getStage() + ", FT3");
                            }
                            else
                            {
                                testLot.setStage("FT3");
                            }
                        }
                       if( result.getString("FT4_6") != null && !"0".equalsIgnoreCase( result.getString("FT4_6") ) )
                       {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                           if( testLot.getQtyIn() != null )
                           {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("FT4_6") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("FT4_6") );
                                }
                            }
                            else
                            {
                                testLot.setQtyIn( result.getString("FT4_6") );
                            }
                            if ( testLot.getStage() != null )
                            {
                                testLot.setStage( testLot.getStage() + ", FT4");
                            }
                            else
                            {
                                testLot.setStage("FT4");
                            }
                        }
                       if( result.getString("FTX") != null && !"0".equalsIgnoreCase( result.getString("FTX") ))
                       {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                           if( testLot.getQtyIn() != null )
                           {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("FTX") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("FTX") );
                                }
                            }
                            else
                            {
                                testLot.setQtyIn( result.getString("FTX") );
                            }
                            if ( testLot.getStage() != null )
                            {
                                testLot.setStage( testLot.getStage() + ", FTX");
                            }
                            else
                            {
                                testLot.setStage("FTX");
                            }
                        }
                       if( result.getString("BI") != null && !"0".equalsIgnoreCase( result.getString("BI") ))
                       {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                           if( testLot.getQtyIn() != null )
                           {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("BI") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("BI") );
                                }
                            }
                            else
                            {
                                testLot.setQtyIn( result.getString("BI") );
                            }
                            if ( testLot.getStage() != null )
                            {
                                testLot.setStage( testLot.getStage() + ", BI");
                            }
                            else
                            {
                                testLot.setStage("BI");
                            }
                        }
                        if( result.getString("FT Hold") != null && !"0".equalsIgnoreCase( result.getString("FT Hold") ) )
                        {
                            testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                            if( testLot.getQtyIn() != null )
                            {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("FT Hold") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("FT Hold") );
                                }
                             }
                             else
                             {
                                testLot.setQtyIn( result.getString("FT Hold") );
                             }
                             if ( testLot.getStage() != null )
                             {
                                testLot.setStage( testLot.getStage() + ", FTHold");
                             }
                             else
                             {
                                testLot.setStage("FTHold");
                             }
                        }

                        if( result.getString("TM") != null && !"0".equalsIgnoreCase( result.getString("TM") ) )
                        {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                           if( testLot.getQtyIn() != null )
                           {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("TM") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("TM") );
                                }
                            }
                            else
                            {
                                testLot.setQtyIn( result.getString("TM") );
                            }
                            if ( testLot.getStage() != null )
                            {
                                testLot.setStage( testLot.getStage() + ", TM");
                            }
                            else
                            {
                                testLot.setStage("TM");
                            }
                        }
                        if( result.getString("SBM") != null && !"0".equalsIgnoreCase( result.getString("SBM") ) )
                        {
                            testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                            if( testLot.getQtyIn() != null )
                            {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("SBM") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("SBM") );
                                }
                             }
                             else
                             {
                                testLot.setQtyIn( result.getString("SBM") );
                             }
                             if ( testLot.getStage() != null )
                             {
                                testLot.setStage( testLot.getStage() + ", SBM");
                             }
                             else
                             {
                                testLot.setStage("SBM");
                             }
                        }
                        if( result.getString("VM") != null && !"0".equalsIgnoreCase( result.getString("VM") ) )
                        {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                           if( testLot.getQtyIn() != null )
                           {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("VM") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("VM") );
                                }
                            }
                            else
                            {
                                testLot.setQtyIn( result.getString("VM") );
                            }
                            if ( testLot.getStage() != null )
                            {
                                testLot.setStage( testLot.getStage() + ", VM");
                            }
                            else
                            {
                                testLot.setStage("VM");
                            }
                        }
                        if( result.getString("BK") != null && !"0".equalsIgnoreCase( result.getString("BK") ) )
                        {
                            testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                            if( testLot.getQtyIn() != null )
                            {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("BK") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("BK") );
                                }
                             }
                             else
                             {
                                testLot.setQtyIn( result.getString("BK") );
                             }
                             if ( testLot.getStage() != null )
                             {
                                testLot.setStage( testLot.getStage() + ", Baking");
                             }
                             else
                             {
                                testLot.setStage("Baking");
                             }
                        }
                       if( result.getString("TR") != null && !"0".equalsIgnoreCase( result.getString("TR") ) )
                       {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                           if( testLot.getQtyIn() != null )
                           {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("TR") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("TR") );
                                }
                            }
                            else
                            {
                                testLot.setQtyIn( result.getString("TR") );
                            }
                            if ( testLot.getStage() != null )
                            {
                                testLot.setStage( testLot.getStage() + ", TR");
                            }
                            else
                            {
                                inventoryLot.setStage("TR");
                            }
                        }
                        if( result.getString("PK") != null && !"0".equalsIgnoreCase( result.getString("PK") ) )
                        {
                            testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                            if( testLot.getQtyIn() != null )
                            {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("PK") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("PK") );
                                }
                             }
                             else
                             {
                                testLot.setQtyIn( result.getString("PK") );
                             }
                             if ( testLot.getStage() != null )
                             {
                                testLot.setStage( testLot.getStage() + ", Paking");
                             }
                             else
                             {
                                testLot.setStage("Paking");
                             }
                        }
                        if( result.getString("FT Else") != null && !"0".equalsIgnoreCase( result.getString("FT Else") ) )
                        {
                           testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                           if( testLot.getQtyIn() != null )
                           {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("FT Else") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("FT Else") );
                                }
                            }
                            else
                            {
                                testLot.setQtyIn( result.getString("FT Else") );
                            }
                            if ( testLot.getStage() != null )
                            {
                                testLot.setStage( testLot.getStage() + ", FtElse");
                            }
                            else
                            {
                                testLot.setStage("FtElse");
                            }
                        }
                        if( result.getString("BE Hold") != null && !"0".equalsIgnoreCase( result.getString("BE Hold") ) )
                        {
                            testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                            if( testLot.getQtyIn() != null )
                            {
                                try
                                {
                                    testLot.setQtyIn( ( Integer.parseInt( testLot.getQtyIn() ) + Integer.parseInt( result.getString("BE Hold") ) ) + "" );
                                }
                                catch(Exception e)
                                {
                                    testLot.setQtyIn( result.getString("BE Hold") );
                                }
                             }
                             else
                             {
                                testLot.setQtyIn( result.getString("BE Hold") );
                             }
                             if ( testLot.getStage() != null )
                             {
                                testLot.setStage( testLot.getStage() + ", BE Hold");
                             }
                             else
                             {
                                testLot.setStage("BE Hold");
                             }
                        }

                        if ( testLot.getQtyIn() != null && !"0".equalsIgnoreCase(testLot.getQtyIn() ) )
                        {
                            testLot.setPartNumber( partNumber );
                            testLot.setLotNumber( lotNumber );
                            testLot.setFabLotNumber( fablotNumber );
                            if ( result.getDate("FT Iss Date", "yyyy/MM/dd") != null )
                            {
                                testLot.setDateIn( StringUtils.formatDateToString(result.getDate("FT Iss Date", "yyyy/MM/dd"), "MM/dd/yyyy" ) );
                            }
                            else if (result.getDate("FT Recv Date", "yyyy/MM/dd") != null)
                            {
                                testLot.setDateIn( StringUtils.formatDateToString(result.getDate("FT Recv Date", "yyyy/MM/dd"), "MM/dd/yyyy" ) );
                            }
                            if (result.getDate("FT SOD", "yyyy/MM/dd") != null  )
                            {
                                testLot.setExpecetedDate( StringUtils.formatDateToString(result.getDate("FT SOD", "yyyy/MM/dd"), "MM/dd/yyyy" ) );
                            }

                            testLot.setLeadCount( result.getString("L/C") );
                            testLot.setPackageType( result.getString("PKG Type") );
                            testLot.setDateCode( result.getString("Date Code") );
                            testLot.setPoNumber( result.getString("Release No"));
                            if ( result.getString("FT Hold") != null && !"0".equalsIgnoreCase( result.getString("FT Hold") ) )
                            {
                               testLot.setStatus(LOT_STATUS_HOLD);
                               testLot.setHoldReason( result.getString("Test Hold Reason") );
                               testLot.setHoldCode( result.getString("Test Hold Code") );
                            }
                            else
                            {
                               testLot.setStatus(LOT_STATUS_RUNNING);
                            }
                            testLot.setPsType( LOCATION_TYPE_FT );
                            if ( lotNumber.endsWith("R") )
                            {
                                testLot.setCategory( LOT_CATEGORY_TYPE_RMA );
                            }
                            else
                            {
                                testLot.setCategory( LOT_CATEGORY_TYPE_PROD );
                            }
                        }
                    }

                    //FG Process
                    if( result.getString("FT FG Bank") != null && !"0".equalsIgnoreCase( result.getString("FT FG Bank") ) )
                    {
                        log( lotNumber + " In FG");
                        inventoryLot = (InventoryLot) m_fgDataMap.get( partNumber + lotNumber + fablotNumber );
                        if ( inventoryLot == null )
                        {
                            inventoryLot = new InventoryLot(VENDOR_NAME_IKANOS_ASECL, LOCATION_TYPE_FG);
                            m_fgDataMap.put(partNumber + lotNumber + fablotNumber, inventoryLot);
                        }

                        if( inventoryLot.getQtyIn() != null )
                        {
                            try
                            {
                                inventoryLot.setQtyIn( ( Integer.parseInt( inventoryLot.getQtyIn() ) + Integer.parseInt( result.getString("FT FG Bank") ) ) + "" );
                            }
                            catch(Exception e)
                            {
                                inventoryLot.setQtyIn( result.getString("FT FG Bank") );
                            }
                         }
                         else
                         {
                            inventoryLot.setQtyIn( result.getString("FT FG Bank") );
                         }
                         if ( inventoryLot.getStage() != null )
                         {
                            inventoryLot.setStage( inventoryLot.getStage() + ", FT Fg Bank");
                         }
                         else
                         {
                            inventoryLot.setStage("FT Fg Bank");
                         }

                         if ( inventoryLot.getQtyIn() != null && !"0".equalsIgnoreCase(inventoryLot.getQtyIn() ) )
                         {
                            inventoryLot.setPartNumber( partNumber );
                            inventoryLot.setLotNumber( lotNumber );
                            inventoryLot.setFabLotNumber( fablotNumber );
                            inventoryLot.setPkgType( result.getString("PKG Type") );
                            inventoryLot.setLeadCount( result.getString("L/C") );
                            inventoryLot.setDateCode( result.getString("Date Code") );
                            inventoryLot.setStatus(LOT_STATUS_RUNNING);
                            inventoryLot.setCustomerPO( result.getString("Release No"));
                            if ( lotNumber.endsWith("R") )
                            {
                                inventoryLot.setCategory( LOT_CATEGORY_TYPE_RMA );
                            }
                            else
                            {
                                inventoryLot.setCategory( LOT_CATEGORY_TYPE_PROD );
                            }
                        }
                    }

                } //Part number Null checking
            }
        }
        catch ( Exception ex )
        {
            System.out.println("ERROR!!!ERROR!!! While Parsing the ASECL Turnkey Wip Report");
            ex.printStackTrace();
            throw ex;
        }
    } // end of prase Turnkey Wip Report method
       

    private void log( String message )
    {
        if ( message == null ) return;

        if ( m_parserLogger != null )
        {
            m_parserLogger.logDebug( message + LINE_SEPARATOR );
        }
        else
        {
            System.out.println( message );
        }
    } // end of log method
}
